package com.srdl.accountRecord.controller;

import com.srdl.accountRecord.pojo.AccountRecord;
import com.srdl.accountRecord.service.AccountRecordService;
import com.utils.common.ServerResponse;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
* 描述:
* author: srdl
* date: 2022-01-05
*/

@RestController
@RequestMapping(value="/accountRecord")
public class AccountRecordController {

    @Autowired
    private AccountRecordService accountRecordService;

    @GetMapping(value="/list")
    public ServerResponse list(AccountRecord accountRecord){
        return accountRecordService.list(accountRecord);
    }

    @GetMapping(value="/pageList")
    public ServerResponse pageList(AccountRecord accountRecord){
        return accountRecordService.pageList(accountRecord);
    }

    @GetMapping(value = "/get/{id}")
    public ServerResponse getById(@PathVariable String id){
    return accountRecordService.get(id);
    }

    @PostMapping(value = "/add")
    public ServerResponse addAccountRecord(@RequestBody @Validated AccountRecord accountRecord){
        return accountRecordService.addAccountRecord(accountRecord);
    }

    @PutMapping(value = "/delete/{id}")
    public ServerResponse deleteAccountRecord(@PathVariable String id){
        return accountRecordService.deleteAccountRecord(id);
    }

    @PostMapping(value = "/update")
    public ServerResponse updateAccountRecord(@RequestBody @Validated AccountRecord accountRecord){
        return accountRecordService.updateAccountRecord(accountRecord);
    }

    @GetMapping(value = "/getSumYearByUserId/{userId}")
    public ServerResponse getSumYearByUserId(@PathVariable String userId){
        return accountRecordService.getSumYearByUserId(userId);
    }

    @GetMapping(value = "/getSumMonthByUserId/{userId}")
    public ServerResponse getSumMonthByUserId(@PathVariable String userId){
        return accountRecordService.getSumMonthByUserId(userId);
    }

    @GetMapping(value = "/getSumDayByUserId/{userId}")
    public ServerResponse getSumDayByUserId(@PathVariable String userId){
        return accountRecordService.getSumDayByUserId(userId);
    }

    @GetMapping(value = "/getThisMonthByUserId/{userId}")
    public ServerResponse getThisMonthByUserId(@PathVariable String userId){
        return accountRecordService.getThisMonthByUserId(userId);
    }

    @GetMapping(value = "/getLastMonthByUserId/{userId}")
    public ServerResponse getLastMonthByUserId(@PathVariable String userId){
        return accountRecordService.getLastMonthByUserId(userId);
    }

}
